package pers.chy.chyappointmentplatform.Service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import pers.chy.chyappointmentplatform.WS.WsClient_HIP;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.scheduling.annotation.Async;
import pers.chy.chyappointmentplatform.WS.WsClient_HIP;


/**
 * 短信服务类
 */
@Service
public class SmsService {

    /**
     * 异步调用：发送短信
     */
    @Async
    public void doSend(String 接收手机, String 短信内容) throws Exception {
        String param =
                "<BSXml>" +
                        "<MsgHeader>" +
                            "<Sender>CAP</Sender>" +
                            "<MsgType>MSG_0101</MsgType>" +
                            "<MsgVersion>3.0</MsgVersion>" +
                        "</MsgHeader>" +
                        "<HospitalArea>1</HospitalArea>"+
                        "<Message>" +
                            "<Receiver>接收手机</Receiver>" +
                            "<Content>短信内容</Content>" +
                        "</Message>" +
                "</BSXml>";

        try {
            param = param
                    .replace("接收手机", 接收手机)
                    .replace("短信内容", 短信内容);
            WsClient_HIP.call("messagesend", "", "", param);

        } catch (Exception e) {
            // 其实在@Async异步方法中抓不到异常
            throw e;
        }
    }
}

